package com.xudow.app.util;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.activeshare.edu.ucenter.models.base.AdvInfo;
import com.xudow.app.ui.ActivityViewActivity;
import com.xudow.app.ui.CourseDetailActivity;

/**
 * 广告图片utilities
 *
 * @author lukecheng
 */
public class AdvertisementUtils {

    /**
     * 根据广告信息打开不同应用
     *
     * @param ctx
     * @param advInfo
     */
    public static void open(Context ctx, AdvInfo advInfo) {
        //1: 活动 2：课程 3：外部链接 4：自编辑页面
        int type = advInfo.getType();

        switch (type) {
            case 1:
                Intent intentActivity = new Intent(ctx, ActivityViewActivity.class);
                intentActivity.putExtra("activityId", advInfo.getRefId());
                ctx.startActivity(intentActivity);
                break;
            case 2:
                Intent intentCourse = new Intent(ctx, CourseDetailActivity.class);
                intentCourse.putExtra("courseId", advInfo.getRefId());
                ctx.startActivity(intentCourse);
                break;
            case 3:
                Uri uri = Uri.parse(advInfo.getPageUrl());
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                ctx.startActivity(intent);
                break;
            case 4:
                //TODO:自编辑页面如何打开
                break;
        }
    }

}
